#ifndef GUN_H
#define GUN_H

#include <QObject>
#include <QVector>
#include "bullet.h"
#include "player.h"

class Player;
class Bullet;

//klasa broni, w przyszlosci moze abstrakcyjna
class Gun : public QObject
{
    Q_OBJECT
public:
    Gun(Player* owner = 0);

    bool fire(qreal x, qreal y, qreal angle);
    void firePressed();
    void fireReleased();
    QVector<Bullet*> getBullets();
    Player* getOwner();
    void setOwner(Player * player);
    int getRecoilTime();
    int getRecoil();
    int getClipSize();
    int getClip();
    int getReloadTime();
    int getReload();
    int getStatus(); //0 - nothing; 1 - reloading
    bool updateGun();
    void setGunAngle(qreal angle);
    qreal getGunAngle();
    void startReloading();
    void finishReloading();
    void resetGun();
    void makeShootingPossible();
private:
    bool isFirePressed;
    bool isRealoading;
    qreal angle;
    Player* owner;
    int recoilTime;
    int recoil;
    int clipSize;
    int clip;
    int reloadTime;
    int reload;
    QVector<Bullet*> bullets;
private slots:
    void onHitPolygon();
    void onHitPlayer(Player*, Player*);
signals:
    void gunFired(Bullet* b);
    void hitPlayer(Player*, Player*);

};

#endif // GUN_H
